<template>

</template>
<script>
import {Loading} from 'element-ui'
export default {
      name:'transit',
      components: {},
      data(){
          return{

          }
      },
      created() {
          Loading.service({
              lock: false,
              text: '拼命加载中...',
              background:'rgba(255,255,255,0.5)',
          });
        this.$http.get(this.$api.API_SSO_ACCESSTOKEN,{code:this.getUrlParam('code')}).then(resp=>{
            console.log(resp,'resp')
            try {
                var jws = new KJUR.jws.JWS();
                var pubKey = KEYUTIL.getKey({ n: 'a1f8160ae2e3c9b465ce8d2d656263362b927dbe29e1f02477fc1625cc90a136e38bd93497c5b6ea63dd7711e67c7429f956b0fb8a8f089adc4b69893cc1333f53edd019b87784252fec914fe4857769594bea4280d32c0f55bf62944f130396bc6e9bdf6ebdd2bda3678eeca0c668f701b38dbffb38c8342ce2fe6d27fade4a5a4874979dd4b9cf9adec4c75b05852c2c0f5ef8a5c1750392f944e8ed64c110c6b647609aa4783aeb9c6c9ad755313050638b83665c6f6f7a82a396702a1f641b82d3ebf2392219491fb686872c5716f50af8358d9a8b9d17c340728f7f87d89a18d8fcab67ad84590c2ecf759339363c07034d6f606f9e21e05456cae5e9a1', e: '010001' });
                jws.parseJWS(resp);
                var result = KJUR.jws.JWS.verify(resp, pubKey, ["RS256"]);
                console.log(result,'==========result')
                var jsondata = JSON.parse(jws.parsedJWS.payloadS);
                console.log(jsondata,'========jsondata')
                var name=jsondata.jnjMSUsername;
                if (name != null && name != "") {
                    window.location.href = "/Frame/LoginMDM.htm?name=" + Encrypt(name) + "";
                } else {
                    window.location.href = "/Frame/LoginMDM.htm";
                }
            } catch (ex) {
                window.location.href = "/Frame/LoginMDM.htm";
            }
        },msg=>{
            window.location.href = "/Frame/LoginMDM.htm";
        });
      },
      methods:{
            getUrlParam:function(name) {
                var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
                var r = window.location.search.substr(1).match(reg);
                if (r != null) return unescape(r[2]);
                return null;
            }
      }
}
</script>
